package com.sky.controller.admin;

import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.dto.SetmealXiuGaiDTO;
import com.sky.entity.SetmealDish;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import com.sky.vo.SetmealHuiXianVO;
import com.sky.vo.SetmealPageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("admin/setmeal")
@Api(tags = "套餐管理")

public class SetmealController {
    @Autowired
    private SetmealService setmealService;
    @PostMapping
    @ApiOperation("新增菜品")
    public Result addSetmeal(@RequestBody SetmealDTO setmealDTO){
        setmealService.addSetmeal(setmealDTO);
        return Result.success();
    }
    @GetMapping("/page")
    @ApiOperation("套餐分页查询")
    public Result<PageResult<SetmealPageVO>> page(SetmealPageQueryDTO setmealPageQueryDTO){
        PageResult pageResult= setmealService.page(setmealPageQueryDTO);
       // PageResult page = setmealService.page(setmealPageQueryDTO);/
        return Result.success(pageResult);
    }
    @ApiOperation("删除套餐")
    @DeleteMapping
    public Result delete(@RequestParam("ids")List<Long>ids){
        setmealService.deleteById(ids);
        return Result.success();
    }
    @ApiOperation("修改套餐回显")
    @GetMapping("/{id}")
    public Result huixian(@PathVariable Long id){
       SetmealHuiXianVO setmealHuiXianVO= setmealService.huixian(id);
       return Result.success(setmealHuiXianVO);
    }
    @ApiOperation("修改套餐")
    @PutMapping
    public Result update(@RequestBody SetmealXiuGaiDTO setmealXiuGaiDTO){
        setmealService.update(setmealXiuGaiDTO);
        return Result.success();
    }
    @ApiOperation("启用禁用")
    @PostMapping("/status/{status}")
    public  Result qinyong(@PathVariable Integer status ,Long id){
        setmealService.qinyong(status,id);
        return Result.success();
    }



}
